<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/material_media/image-upload/style.css">
{extend name="public/base" /}
{block name="style"}
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/index.css?v=111141" />
<link rel="stylesheet" href="__PUBLIC__/admin/material_media/css/index.css?v=111141&times=111" />
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/iconfont.css" />
<link rel="stylesheet" href="__PUBLIC__/admin/material/css/tooltipify.css">
</link>
<link href="/public/plugs/editor/css/toastr.min.css" rel="stylesheet">
<!-- <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css"> -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/material_media/image-upload/style.css">
<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
<link rel="stylesheet" href="__PUBLIC__/admin/upload_layui/css/index.css">
{include file="material/_ali_icon" /}

<style>
    .main-box-body .navs .active {
        background: azure;
        color: #03a9f4;
        border: 1px solid #03a9f4;
        border-radius: 5px;
    }

    a {
        color: #777;
        text-decoration: none;
    }

    a:hover {
        text-decoration: none
    }

    .table tbody>tr>td {
        padding: 0px 8px;
    }

    .table-hover>tbody>tr:nth-child(odd) {
        background-color: #f9f9f9;
    }

    .table-responsive {
        min-height: 470px;
    }
    #sidebar-nav .nav>.open .submenu>li>.submenu a:before,
    #sidebar-nav .nav>.active .submenu>li>.submenu a:before {
        content: "";
    }
	.uploadify-button-text{
		position: relative;
		display: inline-block;
		cursor: pointer;
		background: #fff;
		padding: 0px 5px;
		color: #333;
		text-align: center;
		border-radius: 3px;
		overflow: hidden;
		border: 1px solid #ccc;
	}
	em{
		color: red;
	}
	.col-md-2{width: 20%;}
	.tiktok .panel-body{padding:5px 20px;}
	.tiktok .panel-body img{height: 235px;}
	</style>
{/block}
{block name="body"}

<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-right">
			<button type="button" class="btn btn-warning"> <input class="checkbox check-all" type="checkbox" style="display: inline-block;margin-top: -2px;vertical-align: middle;"> 全选 </button>
			
			<button type="button" class="btn btn-primary" id="createUrl">
				<i class="fa fa-plus"></i> 添加版面<span class="caret"></span>
			</button>
			{if checkAuthRule('del')}<button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>{/if}
		</div>
		<div class="row">
			<form method="get">
				
				{include file="material/_search2" /}
			</form>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<!-- 搜索相关 -->
		{include file="material/_search" /}
		<div id="" class="clear"></div>
					
            {empty name="list" id="vo"}
            {/empty}
			
            <div class="tiktok">
                <div class="row toolTip">
					{volist name="list" id="vo"}
					<div class="col-md-2">
						<div class="panel panel-default">
							<div class="panel-body">
								<img src="{$vo.content}" alt="">
								<div class="num">{$vo.score}</div>
								<input class="ids row-selected" type="checkbox"
									name="id[]" value="{$vo.id}">
							</div>
							<div class="panel-footer">
								<div style="flex: 1;width:0;margin-right: 5px;">
									<span class="title">{$vo.title}</span>
								</div>
								<div>
									<span class="bookTitle">{$vo.book_id_zh}</span>
									<div onclick="editreferral(this)" data-json='{:json_encode($vo)}'>&nbsp;修改</div>
									<div class="downLoad" onclick="downMedia('{$vo.content}',{$vo.id})">
										<button type="button" class="btn btn-danger btn-sm" target="_blank" href="{$vo.content}">
											<i style="color:#fff" class="iconfont icon-xiazai-wenjianxiazai-16"></i>
										</button>
										(<span class="copyNum">{$vo['copy_click_num']}</span>) 
									</div>
								</div>
							</div>
						</div>
					</div>
					{/volist}
                </div>
            </div>
			{$page}
	</div>
</div>

<div class="modal fade" id="create-referral-link-modal">
	<div class="modal-dialog" role="document">
	   <div class="modal-content">
		   <div class="modal-header">
			   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
			   <span style="font-size: 20px;"><span id="referralname">添加</span></span>
		   </div>
		   <div class="modal-body">
			   <div data-bind="visible: loading" class="loading-panel" style="display: none;">
				   <i class="fa fa-spin fa-spinner"></i>
			   </div>
			   <form class="form-horizontal modelform">
				   {include file="material_media/_from" /}
					<div class="form-group">
						<label class="control-label col-sm-2">标题</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="title" value="" placeholder="抖音文案1"/>
						</div>
					</div>

                    <!--头部，相册选择和格式选择-->
					<div class="form-group">
						<label class="control-label col-sm-2">版面图</label>
						<input type="hidden" class="layui-input content" name="content" id="image_content">
						<div class="col-lg-9">
							<button type="button" class="btn btn-primary" id="img_btn">上传</button>
							<div class="layui-upload-list" >
							</div>
							<table></table>
						</div>
					</div>
					
			   </form>
		   </div>
		   <div class="modal-footer">
			   <button type="button" id="createreferral" class="btn btn-primary ">提交</button>
		   </div>
	   </div>
   </div>
</div>

{include file="adsmaterialbook/_from" /}
{/block}
{block name="script"}
<script src="__PUBLIC__/admin/material/js/jquery-tooltipify.min.js"></script>
<script src="/public/plugs/editor/toastr.min.js"></script>
<script type="text/javascript">
	// $(".toolTip [title]").tooltipify();
	function copyContent(elem, id){
		let text = $(elem).parent().parent().parent().siblings().children('.content').html().trim().replace(/<br>/g, `
`);
		var oInput = document.createElement('textarea');//创建一个input标签
		oInput.value = text;//设置value属性
		document.body.appendChild(oInput);//挂载到body下面
		oInput.select(); // 选择对象
		document.execCommand("Copy"); // 执行浏览器复制命令
		oInput.className = 'oInput';
		oInput.style.display='none';
		
		var url = "{:url('copy')}";
		$.ajax({
			type: "POST",
			url: url,
			data:{id:id},
			dataType: "json",
			success: function(data){
				if(data.code==1){
					toastr.success('复制成功');
					setTimeout(function() {	
						window.location.reload();
					}, 1500);
				}else{
					updateAlert("失败，"+data.msg, 'danger');
				}
			},
			error : function(e){
				console.log(e.status);
				console.log(e.responseText);
			}
		})

	}
	function follow(ee, id){
		var url = "{:url('addFollow')}";
		$.ajax({
			type: "POST",
			url: url,
			data:{id:id},
			dataType: "json",
			success: function(data){
				if(data.code==1){
					toastr.success(data.msg);
					setTimeout(function() {	
						window.location.href = "{:url('my_1_1')}?platform_ids=3";
					}, 1000);
				}else{
					updateAlert("失败，"+data.msg, 'danger');
				}
			},
			error : function(e){
				console.log(e.status);
				console.log(e.responseText);
			}
		})
	}
</script>
<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugs/webuploader/webuploader.custom.js"></script>

<script type="text/javascript">

$(function() {
	$('#createUrl').on('click',function(){
		var is_rule = '{:checkAuthRule("add")}';
		if(!is_rule){
			layer.msg("你没权限添加");
			return;
		}

		var $modal = $('#create-referral-link-modal');
		$modal.on('shown.bs.modal', function () {
			uploader();
		});	
		$modal.modal({backdrop: 'static', keyboard: false});
	});
	$("#createreferral").on('click',function(){
		var data = $('.modelform').serializeJson();
		console.log(data);
		if (data['content'].length==0 && $("#field_ebook").val() == '') {
			updateAlert("不能为空", 'danger');
			return false;
		}
		var url = "{:url('add')}";
		$.ajax({
			type: "POST",
			url: url,
			data:data,
			dataType: "json",
			success: function(data){
				if(data.code==1){
					updateAlert(data.msg, 'success');
					setTimeout(function() {	
						window.location.reload();
					}, 100);
				}else{
					updateAlert("添加，"+data.msg, 'danger');
				}
			},
			error : function(e){
				console.log(e.status);
				console.log(e.responseText);
			}
		})
	});
});

$('.panel-body .show').click(function(){
	$(this).parent().parent().siblings().show()
})
$('.mask i').click(function(){
	$(this).parent().hide()
})

</script>
{include file="material/pub_footer"}
{/block}